//
//  HomeViewController.m
//  LoveTrail
//
//  Created by giantumbrella on 15/6/9.
//  Copyright (c) 2015年 赵娟. All rights reserved.


#import "HomeViewController.h"

#import "CommonMacro.h"
#import "PopViewController.h"
#import "RewardPopVC.h"
#import "ScrollViewView.h"
#import "ThreeButtonAddView.h"
#import "SixModulesInterfaceView.h"
#import "GuessYouLikeView.h"
#import "ClubVVC.h"
#import "BrandSpecilTableVC.h"
#import "GoodChannelTableVC.h"

@interface HomeViewController ()<clickSixDifferentButtonDelegate,threeButtonClickDelegate,clickCellEnterOtherViewDelegate>{
    
    NSMutableArray * allArray,*titleArr,*pictureArr,*priceArr,*lastNumArr;
}
@property (nonatomic,strong) PopViewController *popVC;
@property (nonatomic,strong) RewardPopVC *rewardPopVC;
@property (nonatomic,strong)  ScrollViewView *scrollViewView;
@property (nonatomic,strong)  ThreeButtonAddView *threeButtonAddView;
@property (nonatomic,strong) SixModulesInterfaceView *sixModelesView;
@property (nonatomic,strong) GuessYouLikeView *guessYouLikeView;
@property (nonatomic,strong) UILabel *guessTextLabel;
@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //popView
    self.popVC = [[PopViewController alloc] init];
    self.rewardPopVC = [[RewardPopVC alloc] init];
    self.view.backgroundColor = UIColorWithRGBA(242, 242, 242, 242);
    [self addViewSubViews];
    //摆放tabBar和Search
    [self addSubViews];
}

#pragma mark 跳出菜单
#pragma mark 弹出视图
-(void)popView:(UIBarButtonItem *)sender
{
    [self.popVC popView];
}

- (void)popRewardView:(UIBarButtonItem *)sender
{
    [self.rewardPopVC popRewardView];
}

#pragma mark 摆放tabBar和Search
- (void)addSubViews
{
    //左侧按钮
    UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"head_type@2x"] style:UIBarButtonItemStyleDone target:self action:@selector(popView:)];
    self.navigationItem.leftBarButtonItem = leftButton;
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
    
    //右侧按钮
    UIBarButtonItem *rightButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"签到@2x"] style:UIBarButtonItemStylePlain target:self action:@selector(popRewardView:)];
    self.navigationItem.rightBarButtonItem = rightButtonItem;
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];

    //搜索栏
    self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(100.0f,10, SCREEN_WIDTH*120.320, 40.0f)];
    self.searchBar.delegate =self;
    self.searchBar.placeholder = @"搜索";
    self.searchBar.showsCancelButton = NO;
    self.searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
    self.searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
    self.searchBar.keyboardType = UIKeyboardTypeDefault;
    self.navigationItem.titleView = self.searchBar;
    
}

#pragma mark 添加self.view的可是界面
- (void)addViewSubViews
{
    //0.添加背景滚动视图
    self.bgScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [self.view addSubview:self.bgScrollView];
    self.bgScrollView.showsVerticalScrollIndicator = NO;
    self.bgScrollView.contentSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT*2.5);
    
    
    //1.头部滚动视图
    self.scrollViewView = [[ScrollViewView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT*0.23)];
    [self.bgScrollView addSubview:self.scrollViewView];
    
    //2.添加三个按钮
    self.threeButtonAddView = [[ThreeButtonAddView alloc] initWithFrame:CGRectMake(0, self.scrollViewView.frame.size.height+self.scrollViewView.frame.origin.y, self.scrollViewView.frame.size.width, self.scrollViewView.frame.size.height*0.44)];
    [self.bgScrollView addSubview:self.threeButtonAddView];
    self.threeButtonAddView.threeButtonClickDelegate = self;
    
    //3.六个 模块
    self.sixModelesView = [[SixModulesInterfaceView alloc] initWithFrame:CGRectMake(0, self.threeButtonAddView.frame.size.height+self.threeButtonAddView.frame.origin.y+5, SCREEN_WIDTH, SCREEN_HEIGHT*0.63)];
    [self.bgScrollView addSubview:self.sixModelesView];
    self.sixModelesView.sixButtonDelegate = self;
//    self.sixModelesView.backgroundColor = [UIColor redColor];
    
    //猜你喜欢 几个字
    self.guessTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.sixModelesView.frame.size.height+self.sixModelesView.frame.origin.y, SCREEN_WIDTH, 20)];
    [self.scrollViewView addSubview:self.guessTextLabel];
    self.guessTextLabel.textColor = UIColorWithRGBA(250, 172, 209, 1);
    self.guessTextLabel.font = [UIFont systemFontOfSize:11];
    self.guessTextLabel.textAlignment = NSTextAlignmentCenter;
    self.guessTextLabel.text = @"猜你喜欢";
    
    //4.猜你喜欢
    self.guessYouLikeView = [[GuessYouLikeView alloc] initWithFrame:CGRectMake(0, self.guessTextLabel.frame.size.height+self.guessTextLabel.frame.origin.y, SCREEN_WIDTH, SCREEN_HEIGHT*0.9)];
    [self.view addSubview:self.guessYouLikeView];
//    self.guessYouLikeView.backgroundColor = [UIColor greenColor];
    [self.scrollViewView addSubview:self.guessYouLikeView];
    self.guessYouLikeView.clickCellEnterDelegate = self;
}


#pragma mark 六个 模块 点击之后 clickSixDifferentButtonDelegate
- (void)clickSixDifferentButton:(UIButton *)button
{
    if (button.tag==1000) {
           }
    if (button.tag==1001) {
            }
    if (button.tag==1002) {
        
    }
    if (button.tag==1003) {
        
    }
    if (button.tag==1004) {
    }
    if (button.tag==1005) {
        BrandSpecilTableVC *brandSpecil = [[BrandSpecilTableVC alloc] init];
        UINavigationController *brandSNav = [[UINavigationController alloc] initWithRootViewController:brandSpecil];
        [self presentViewController:brandSNav animated:YES completion:nil];
    }
    if (button.tag==1006) {
        GoodChannelTableVC *goodChannel = [[GoodChannelTableVC alloc]init];
        UINavigationController *goodChannelNav = [[UINavigationController alloc] initWithRootViewController:goodChannel];
        [self presentViewController:goodChannelNav animated:YES completion:nil];
    }
    if (button.tag==1007) {
        ClubVVC *clubView = [[ClubVVC alloc] init];
        [self presentViewController:clubView animated:YES completion:nil];
    }
}

#pragma mark threeButtonClickDelegate
- (void)threeButtonClick:(UIButton *)button
{
    NSLog(@"点击了 三个按钮");
}

#pragma mark-- clickCellEnterOtherViewDelegate 点击cell
- (void)clickCellEnterOtherView:(NSInteger)index
{
    NSLog(@"cell 点击了---");
}
//搜索栏取消键取消第一响应


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


@end
